/**
 *<p>Copyright: Copyright (c) 2012</p> 
 *<p>Company: SCPII</p>
 *<p>Project:scpii-api</p>
 *@author xiezhouyan
 *@Date 2013-3-8 下午5:22:51
 *@version 1.0
 *@description:
 */
package com.scpii.api.controller.app;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.scpii.api.common.base.BaseController;
import com.scpii.api.domain.app.AppNodes;
import com.scpii.api.service.app.AppNodesService;
import com.scpii.api.util.PrincipalUtil;

@Controller
@RequestMapping("/app/nodes")
public class NodesController extends BaseController {

	@Resource
	private AppNodesService appNodesService;

	@PreAuthorize("hasRole('ROLE_CLIENT')")
	@RequestMapping(value = "/parent/{parentId}", method = RequestMethod.GET)
	@ResponseBody
	public List<AppNodes> getAppNodesByParentId(
			@PathVariable("parentId") Long parentId) {
		Long appId = PrincipalUtil.getPrincipal().getAppId();
		return appNodesService.selectByAppIdAndParentId(appId, parentId);
	}

}
